// src/renderer/index.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import axios from 'axios';
import { HashRouter } from 'react-router-dom';
import { Provider as JotaiProvider } from 'jotai';
import App from './App';
import settings from './config/settings';
import { ConfigProvider } from './react-providers';

axios.defaults.baseURL = 'http://localhost:8000';

async function main() {
  ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
    <React.StrictMode>
      <JotaiProvider>
        <HashRouter>
          <ConfigProvider
            value={{
              workspaceDir: '',
              extWorkerHost: '',
              isElectronRenderer: true,
            }}
          >
            <App />
          </ConfigProvider>
        </HashRouter>
      </JotaiProvider>
    </React.StrictMode>
  );

  try {
    postMessage({ payload: 'removeLoading' }, '*');
  } catch {}

  console.log('%c[App version]', 'color: #4e88ff;', settings.version);
}

main();
